package com.livepan.server.service.model;


import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Objects;

public class SubmissionModel {
    private Integer runId;

    @NotBlank(message = "提交时间不能为空")
    private String submitTime;

    private Byte result;

    @NotNull(message = "题目id不能为空")
    private Integer problemId;

    @NotNull(message = "试卷id不能为空")
    private Integer contestId;

    @NotNull(message = "用户id不能为空")
    private String userId;

    private Integer timeused;

    private Integer memoryused;

    private Integer length;

    @NotNull(message = "语言不能为空")
    private Short language;

    @NotBlank(message = "源代码不能为空")
    private String sourcecode;

    private String ext;

    private Integer score;

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public String getSourcecode() {
        return sourcecode;
    }

    public void setSourcecode(String sourcecode) {
        this.sourcecode = sourcecode == null ? null : sourcecode.trim();
    }

    public String getExt() {
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext == null ? null : ext.trim();
    }

    public Integer getRunId() {
        return runId;
    }

    public void setRunId(Integer runId) {
        this.runId = runId;
    }

    public String getSubmitTime() {
        return submitTime;
    }

    public void setSubmitTime(String submitTime) {
        this.submitTime = submitTime == null ? null : submitTime.trim();
    }

    public Byte getResult() {
        return result;
    }

    public void setResult(Byte result) {
        this.result = result;
    }

    public Integer getProblemId() {
        return problemId;
    }

    public void setProblemId(Integer problemId) {
        this.problemId = problemId;
    }

    public Integer getContestId() {
        return contestId;
    }

    public void setContestId(Integer contestId) {
        this.contestId = contestId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Integer getTimeused() {
        return timeused;
    }

    public void setTimeused(Integer timeused) {
        this.timeused = timeused;
    }

    public Integer getMemoryused() {
        return memoryused;
    }

    public void setMemoryused(Integer memoryused) {
        this.memoryused = memoryused;
    }

    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }

    public Short getLanguage() {
        return language;
    }

    public void setLanguage(Short language) {
        this.language = language;
    }

    @Override
    public String toString() {
        return "SubmissionModel{" +
                "runId=" + runId +
                ", submitTime='" + submitTime + '\'' +
                ", result=" + result +
                ", problemId=" + problemId +
                ", contestId=" + contestId +
                ", userId='" + userId + '\'' +
                ", timeused=" + timeused +
                ", memoryused=" + memoryused +
                ", length=" + length +
                ", language=" + language +
                ", sourcecode='" + sourcecode + '\'' +
                ", ext='" + ext + '\'' +
                '}';
    }

    //todo 这里用的并不好
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SubmissionModel that = (SubmissionModel) o;
        return
                problemId.equals(that.problemId) &&
                        contestId.equals(that.contestId) &&
                        userId.equals(that.userId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(problemId, contestId, userId);
    }
}
